package com.ghf.dp1.sample;

//简单工厂
//新增计算类型只需要继承 Operation 类,再扩展 createOperation 方法,不用修改其他的计算逻辑
public class OperationFactory {

    public static Operation createOperation(String opt){
        switch (opt){
            case "+":
                return new OptAdd();
            case "-":
                return new OptSub();
            default:
                return new Operation();
        }
    }
}
